<template>
	<view>
		<mtitles :showBack="false" titleDdx="炖大侠" name="颐而康外膳" textLeft="left" paddinLeft="46rpx" bgColor="linear-gradient(167deg, #09EC8D -50.6%, #FFF 106.77%)">
		</mtitles>
		<tb-privacy ref="prcy" :onNeed='true'></tb-privacy>
		<scroll-view class="container" scroll-y="true" @scroll="boxScroll"
			@refresherrefresh="refresh" scroll-with-animation refresher-enabled="true" :refresher-triggered="refLoad">
			<view v-if="!loaded" class="imgEmpty" :style="{ top: `${state.customBar}px` }">
				<image class="emtimg" :src="env.FileUrl+'foood/ico/images/home_def01.png'" mode="aspectFill"></image>
			</view>
			<!-- <scroll-view class="container" scroll-y="true" @scroll="boxScroll" @refresherrefresh="refresh" scroll-with-animation
			refresher-enabled="true" :refresher-triggered="refLoad"> -->
			<view class="padmbot">
				<!-- <view :style="{height:`${state.customBar}px`}"></view> -->
				<view class="topSec" :style="{paddingTop:`${state.customBar}px`}">
					<view class="padding-top">
						<tb-advSwiper :list="advList" :radius="20" :paddinglr="'0 36rpx'" :height="280" :autoPlay="true"></tb-advSwiper>
					</view>
				</view>
				<view class="bg_boxx">
					<view class="flex flex-wrap navBox lh_z padding-top-xs">
						<view v-for="(item,index) in navList" :key="index" :id="'id'+index" :data-nid="index"
							@click="tapNavItem(item)" class="d_ib point">
							<view class="navItem text-center flex flex-direction justify-center p_rlt">
								<view class="">
									<view class="d_ib icoBox text-acenter">
										<image class="icoimg" :src="env.imgBaseUrl+item.src" mode="aspectFit"></image>
									</view>
								</view>
								<view class="nvtext text-lg">
									{{item.name}}
								</view>
							</view>
						</view>
					</view>
					<!-- 第一版专区券样式 -->
					<!-- <view class="p_rlt margin-top"
							@click="changeMenuCach('add',{id:'1',source:'home',action:'changeVip'},'/pages/index/menu/menu')">
							<tb-image width="100%" height="276rpx" :src="env.FileUrl + 'food/images/home_bn01.png'">
								<template v-slot:error>
									<image src="../../../static/homeEmpty.png" class="imms" mode="aspectFill"></image>
								</template>
							</tb-image>
							<view class="nadm_cont padding-top padding-lr text-center" v-if="assountMoney>0">
								<view class="nad_tit text-white text-sm flex flex-direction justify-center">
									<view class="">
										我的VIP特价
									</view>
									<view class="">
										专区专区券
									</view>
								</view>
								<view class="nadtext flex justify-center align-center margin-top-sm">
									<text class="d_ib p_rlt nad_line lef"></text>
									<text class="d_ib padding-lr-xs">累计总额</text>
									<text class="d_ib p_rlt nad_line"></text>
								</view>
								<view class="flex align-center justify-center">
									<view class="d_ib text-bold text-center text48">
										{{assountMoney}}
									</view>
									<view class="d_ib text-xs margin-left-xxs">
										<view class="text-nred">
											内
										</view>
										<view class="text-c6">
											元
										</view>
									</view>
								</view>
							</view>
							<view class="nadm_cont padding-top text-center" v-else>
								<view class="nullVip_t">
									VIP专区券
								</view>
								<view class="nullVip_t_sub">
									尊享美食
								</view>
								<view class="nullVip_t_sub_d">
									低于市均价，品质不打折
								</view>
								<view class="nullVip_toView">
									去看看
								</view>
							</view>
						</view> -->
					<view class="specSec margin-left margin-top-lg margin-bottom-sm"
						v-if="specList && specList.length > 0">
						<view class="flex align-center padding-top-xs padding-left-sm">
							<view class="flex-sub text-bold text-ngreen text-lg">
								今日特价
							</view>
							<view class="d_ib mspbtn text-sm padding-lr-sm padding-tb-xs"
								@click="changeMenuCach('add',{id:'1',source:'home',action:'tejia'},'/pages/index/menu/menu')">
								更多<text class="cuIcon-right"></text>
							</view>
						</view>
						<view class="spe_box">
							<view v-for="(item,index) in specList" :key="index" class="spe_cel"
								@click="mnavTo('/pages/order/goodsDetial/goodsDetial?shopType=' + '' + '&goodsId=' + item.goods_id + '&source=tejia')">
								<view class="text-center">
									<tb-image width="130rpx" height="130rpx" borderRadius="20rpx"
										border="0.5px solid rgba(0, 0, 0, 0.05)"
										:src="env.imgBaseUrl + item.vmaster_product_image_id"></tb-image>
								</view>
								<view class="padtmd text-cuts">
									{{item.name}}
								</view>
								<view class="text-c9 text-xs text-cuts minh38 text-center">
									<text style="color:#FC4C40;font-size: 28rpx;font-weight: 700;">¥{{item.activity_price}}</text>
									<text v-if="item.vname">/{{item.vname}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="text-lg text-bold padding-top-sm padding-bottom-xs padding-left" :style="{marginTop:specList && specList.length > 0?'':'30rpx'}">
					大家都在吃
				</view>
				<view class="">
					<!-- :left-gap="leftGap"
							:right-gap="rightGap"
							:column-gap="columnGap" 
							@remove="remove"
							-->
					<!-- 添加瀑布流 -->
					<uv-waterfall ref="waterfall" v-model="waterFulls.list" :add-time="10" :left-gap="30"
						:right-gap="30" :column-gap="30" @changeList="changeList">
						<!-- 第一列数据 -->
						<template v-slot:list1>
							<!-- 为了磨平部分平台的BUG，必须套一层view -->
							<view>
								<!-- :style="{marginTop:specList && specList.length > 0?'':'30rpx'}" -->
								<view class="d_ib lsItem" v-for="(item,index) in waterFulls.list1" :key="index"
									@click="mnavTo('/pages/user/evalDetails/evalDetails?goodsId=' +  item.goods_id + '&sellMemberId=' + item.sell_member_id + '&bill_id=' + item.bill_id)">
									<tb-image width="100%" height="352rpx" borderRadius="20rpx 20rpx 0 0"
										:src="env.imgBaseUrl + item.src">
										<template v-slot:error>
											<image src="../../../static/menuEmpty.png" class="imms" mode="aspectFill">
											</image>
										</template>
									</tb-image>
									<view class="itm_cont bg-white">
										<view class="itm_txt break-all">
											{{item.title}}
										</view>
										<view class="flex align-center text-c6 margin-top-xs">
											<view class="flex-sub flex align-center">
												<view class="flex-sub padding-tb-sm flex align-center padding-left-xs">
													<text class="fcon-pinglun text-xll"></text>
													<view class="text-center marLeft12">{{item.ndiscuss_nums||0}}</view>
												</view>
												<view class="flex-sub padding-tb-sm flex align-center"
													@click.stop="tapzItem(item,'zan')">
													<text class="text-xll"
														:class="item.iszan?'fcon-yizan1':'fcon-zan1'"></text>
													<view class="text-center marLeft12" v-if="item.nfavourable_nums">
														{{item.nfavourable_nums}}
													</view>
												</view>
											</view>
											<view
												class="d_ib padding-left-xs padding-right-sm padding-tb-xs p_rlt lefsld"
												@click.stop="tapzItem(item,'cai')">
												<text class="text-xll"
													:class="item.iscai?'fcon-yicai1':'fcon-cai1'"></text>
											</view>
										</view>
									</view>
								</view>
							</view>
						</template>
						<!-- 第二列数据 -->
						<template v-slot:list2>
							<!-- 为了磨平部分平台的BUG，必须套一层view -->
							<view>
								<view class="d_ib lsItem" v-for="(item,index) in waterFulls.list2" :key="index"
									@click="mnavTo('/pages/user/evalDetails/evalDetails?goodsId=' +  item.goods_id + '&sellMemberId=' + item.sell_member_id + '&bill_id=' + item.bill_id )">
									<tb-image width="100%" height="352rpx" borderRadius="20rpx 20rpx 0 0"
										:src="env.imgBaseUrl + item.src">
										<template v-slot:error>
											<image src="../../../static/menuEmpty.png" class="imms" mode="aspectFill">
											</image>
										</template>
									</tb-image>
									<view class="itm_cont bg-white">
										<view class="itm_txt break-all">
											{{item.title}}
										</view>
										<view class="flex align-center text-c6 margin-top-xs">
											<view class="flex-sub flex align-center">
												<view class="flex-sub padding-tb-sm flex align-center padding-left-xs">
													<text class="fcon-pinglun text-xll"></text>
													<view class=" text-center marLeft12">{{item.ndiscuss_nums||0}}
													</view>
												</view>
												<view class="flex-sub padding-tb-sm flex align-center"
													@click.stop="tapzItem(item,'zan')">
													<text class="text-xll "
														:class="item.iszan?'fcon-yizan1':'fcon-zan1'"></text>
													<view class="text-center marLeft12" v-if="item.nfavourable_nums">
														{{item.nfavourable_nums}}
													</view>
												</view>
											</view>
											<view
												class="d_ib padding-left-xs padding-right-sm padding-tb-xs p_rlt lefsld"
												@click.stop="tapzItem(item,'cai')">
												<text class="text-xll"
													:class="item.iscai?'fcon-yicai1':'fcon-cai1'"></text>
											</view>
										</view>
									</view>
								</view>
							</view>
						</template>
					</uv-waterfall>

					<!-- <view class="d_ib lsItem" v-for="(item,index) in 6" :key="index">
								<tb-image width="100%" height="352rpx" borderRadius="20rpx 20rpx 0 0" :src="env.FileUrl + 'food/images/home/home_img01.png'"></tb-image>
								<view class="itm_cont bg-white">
									<view class="itm_txt">
										脆爽开胃，下饭一绝..
									</view>
									<view class="flex align-center text-c6 margin-top-xs">
										<view class="flex-sub flex align-center">
											<view class="flex-sub padding-tb-sm flex align-center padding-left-xs">
												<text class="fcon-a-Frame427320609"></text>
												<view class="flex-sub text-center">140</view>
											</view>
											<view class="flex-sub padding-tb-sm flex align-center">
												<text class="fcon-zan1 text-xl"></text>
												<view class="flex-sub text-center">1000</view>
											</view>
										</view>
										<view class="d_ib padding-lr-sm padding-tb-xs p_rlt lefsld">
											<text class="fcon-cai1 text-xl"></text>
										</view>
									</view>
								</view>
							</view> -->
				</view>

				<!-- 第二版专区券样式 -->
				<!-- <view class="Vipcoupon-con flex flex-direction align-center" @click="changeMenuCach('add',{id:'1',source:'home',action:'changeVip'},'/pages/index/menu/menu')">
						  <text class="text-con" v-if="assountMoney">您有</text>
						  <text v-else class="text-con1">VIP特价专区</text>
							<view class="flex text-pic" v-if="assountMoney">
								<text>¥</text>
								<text>{{assountMoney}}</text>
							</view>
							<view class="text-pic" v-else>
								<view style="font-size: 20rpx;color:#333;text-align: center;">买水果、美食</view>
								<view style="text-align: center;">
									<text><text class="pic_subtext">券后</text>{{discountNums}}<text class="pic_subtext">折起</text></text>
								</view>
							</view>
							<text class="ipcoupon-zigh" v-if="assountMoney">VIP特价专区</text>
							<text class="ipcoupon-fwxm"><text v-if="assountMoney">买水果、美食</text> <text
									v-else>低于市均价,品质不打折</text> </text>
							<view class="ipcoupon-dazhe"><text v-if="assountMoney">享<text>{{discountNums}}折起</text></text></view>
							<text class="vipcoupon-btn flex justify-center align-center" v-if="assountMoney">去使用</text>
							<text class="vipcoupon-btn1 flex justify-center align-center" v-else>去看看</text>
					</view> -->
			</view>
		</scroll-view>
		
		<!-- 暂注释多套 -->
		
		<view v-if="mealsOrderList&&mealsOrderList.length" class="botSec" :style="{bottom:isPhonex ? '150rpx !important' : '130rpx !important'}">
			<!-- @clickItem=clickItem -->
			<uni-swiper-dot class="uni-swiper-dot-box" :info="mealsOrderList" :current="swiperDotIndex" :mode="'round'" :dots-styles="dotsStyles">
				<swiper class="swboxdt" @change="changeSwiper" :autoplay="autoPlay" :current="swiperDotIndex" circular>
					<swiper-item class="flex align-center lh_z" v-for="(item, index) in mealsOrderList" :key="index">
						<view class="padding-left-xl flex-sub">
							<view class="text-xll text-bold text-ngold text-cut">
								{{item.goods_name||''}}
							</view>
							<view class="texta7 text-sm padding-top-sm">
								已约餐{{item.use_nums||0}}次，累计消费{{item.total_money||0}}元
							</view>
						</view>
						<view class="mrtwf">
							<view class="bs_btn point" @click="tapToMenu(item)">
								去约餐
							</view>
							<view v-if="item.delivery_mode&&item.delivery_mode!='1181'" class="padding-top-xs text-sm texta7 text-center">
								<!-- 已设置自动点餐 -->
								{{`已设置${item.delivery_mode=='1178'?'天天送':item.delivery_mode=='1179'?'工作日送':item.delivery_mode=='1180'?'周末送':item.delivery_mode=='1182'?'自定义约餐':''}`}}
							</view>
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>
		<view v-if="state.scrollTop>400" class="top_box point" @click.stop="toTopClick">
			<text class="fcon-a-huidaodingbu11 tpico d_ib"></text>
		</view>
		<dragButtons :changeX="changeDrag" :showStatus="showNav" isDock @btnTouchend="dragTouchend" :initLimitY="160" :limitY="160"
			:existTabBar="true" :maxWidth="644">
			<view class="Vipcoupon-con flex flex-direction align-center"
				@click="changeMenuCach('add',{id:'1',source:'home',action:'changeVip'},'/pages/index/menu/menu')">
				<text class="text-con" v-if="assountMoney">您有</text>
				<text v-else class="text-con1">VIP专区</text>
				<view class="flex text-pic" v-if="assountMoney">
					<text class="txtv">¥</text>
					<text class="txtv">{{assountMoney}}</text>
				</view>
				<view class="text-pic" v-else>
					<view style="font-size: 24rpx;color:#333;text-align: center;">买美食、水果</view>
					<view style="text-align: center">
						<text class="txtv"><text class="pic_subtext txtv">券后</text>{{discountNums}}<text
								class="txtv pic_subtext">折起</text></text>
					</view>
				</view>
				<text class="ipcoupon-zigh" v-if="assountMoney">VIP专区券</text>
				<!-- <view class="ipcoupon-fwxm" :style="{paddingTop:assountMoney?'15rpx':'45rpx'}">{{assountMoney ? '买水果、美食' : '低于市均价,品质不打折'}}</view>
				<view class="ipcoupon-dazhe" v-if="assountMoney"><text>享<text>{{discountNums}}折起</text></text></view>
				<text class="vipcoupon-btn flex justify-center align-center" v-if="assountMoney">去使用</text>
				<text class="vipcoupon-btn1 flex justify-center align-center" v-else>去看看</text> -->
				<view class="coup_bottom_style">
					<view class="ipcoupon-fwxm" :style="{marginTop:assountMoney?'':'20rpx'}">
						{{assountMoney ? '买美食、水果' : '低于市均价,品质不打折'}}</view>
					<view class="ipcoupon-dazhe" v-if="assountMoney"><text class="txtt">享<text>{{discountNums}}折起</text></text>
					</view>
					<text class="vipcoupon-btn flex justify-center align-center" v-if="assountMoney">去使用</text>
					<text class="vipcoupon-btn1 flex justify-center align-center" v-else>去看看</text>
				</view>
			</view>
		</dragButtons>
		<tabbar :thisCurrent="curRoute"></tabbar>
	</view>
</template>

<script setup lang="ts">
	import { ref, reactive, nextTick } from 'vue';
	import { onShow, onLoad,onHide, onPullDownRefresh, onReachBottom, onPageScroll, onShareAppMessage } from '@dcloudio/uni-app';
	import { env } from '@/api/env.js';
	import { getShareDetail, getCredAccount, getGoodsLikeList, getTemplate, getlikeorStepon, getSpecialFood,getMealsOrder} from '@/api/vmeitime-http/index.js'
	import { takeSaveShare, initShop } from '@/utils/public';
	import { mnavTo, checkOrg, checkLogin, showLoading, hideLoading,getCurRoute,getSystemPhoneX } from '@/utils/helper';
	import { useShopStore } from '@/stores/shopStore';
	import mapi from '@/utils/mapi'
	import dragButtons from "@/components/dragButton/drag-button.vue"
	const prcy = ref(null)
	const isPhonex = ref<any>(false);
	const shopStore = useShopStore();
	const assountMoney = ref(0);
	const changeDrag = ref(false);
	const showNav = ref(false);
	const discountNums = ref("8.5");
	const dragDirect = ref('right');
	const specList = ref<any>();
	const marginTop = ref(0) //顶部导航栏
	const pageInfo = ref({
		curPage: 1,
		pageSize: 10,
		backCupPage: 2
	});
	const waterFulls = ref({
		list: [],
		list1: [],
		list2: []
	});
	const advList = ref<any>([]);
	const navList = ref<any>([]);
	let state = reactive({
		// advList: [
		// 	{
		// 		src: 'food/images/home_swiper01.png',
		// 		url: ''
		// 	},
		// 	{
		// 		src: 'food/images/home_swiper01.png',
		// 		url: ''
		// 	}
		// ],
		specList: [],
		statusBar: 0,
		customBar: 0,
		navList: [
			{
				id: '0',
				name: '充值中心',
				src: 'food/images/home_nav01.png',
				url: '/pages/user/recharge/recharge'
			},
			{
				id: '1',
				name: '预定专区',
				src: 'food/images/home_nav02.png',
				url: ''
			},
			{
				id: '2',
				name: '健康商城',
				src: 'food/images/home_nav03.png',
				url: '',
				type: 'xcx'
			},
			{
				id: '3',
				name: '分享有礼',
				src: 'food/images/home_nav04.png',
				url: '/pages/user/brandIntr/brandIntr?type=1001'
			},
			{
				id: '4',
				name: '品牌故事',
				src: 'food/images/home_nav05.png',
				url: '/pages/user/brandIntr/brandIntr?type=1002'
			}
		],
		isShowToTop: false,
		scrollTop: 0
	});
	const pageInfoTj = ref({
		curPage: 1,
		pageSize: 4
	})
	// onPullDownRefresh(() => {
	// 	loadData({ source: 'refresh' });
	// 	mapi.msg('刷新成功!')
	// 	uni.stopPullDownRefresh();
	// });
	const refLoad = ref(false)
	const refresh = () => {
		refLoad.value = true
		setTimeout(() => {
			refLoad.value = false
		}, 500)
		initShop(loadData, { source: 'refresh' });
	}
	// 触底加载更多
	onReachBottom(() => {
		getLikeList('add');
	});
	
	const dotsStyles = {width:6,backgroundColor: '#a7a8b7',border: '1px #a7a8b7 solid',color: '#a7a8b7',selectedBackgroundColor: 'rgba(247, 208, 110, 0.7)',selectedBorder: '1px rgba(247, 208, 110, 0.6) solid'};//#70DEB1
	const swiperDotIndex = ref(0);
	const autoPlay = ref(true);
	const changeSwiper = (e:any) => {
		// console.log('changeSwiper',e)
		swiperDotIndex.value = e.detail.current;
	}
	
	const mealsOrderList = ref<any>([
		// {
		// 	bill_id:'10202411141041028356872',
		// 	gell_member_id:'',
		// 	goods_id:'',
		// 	goods_name:'随心配多套1113',
		// 	pre_mums:7,
		// 	use_nums:0,
		// 	surplus_mus:7,
		// 	delivery_mode:'1178'
			
		// }
	]);
	 
	const getSwipers = async () => {
		let res = await getTemplate({ vscope: shopStore.curSellerMemberId, vtype: "831", vstatus: "829" })
		loaded.value = true
		console.log(res, "redsdd")
		if (!res.result) {
			return
		}
		advList.value = []
		navList.value = []
		for (let item of res.object.positionList) {
			if (item.vbus_code == 'A100') {
				for (let i of item.positionContentList) {
					advList.value.push({
						src: i.vimage_url,
						url:i.vaction
					})
				}
			}
			if (item.vbus_code == 'B800') {
				for (let items in item.positionContentList) {
					navList.value.push({
						id: items,
						name: item.positionContentList[items].vname,
						src: item.positionContentList[items].vimage_url,
						url: item.positionContentList[items].vaction,
						type: item.positionContentList[items].ncontent_id,
						vaction_type:item.positionContentList[items].vaction_type
					})
				}
			}
			if (item.vbus_code == 'B801'&&item.positionContentList) {
				const simg = item.positionContentList[0]&&item.positionContentList[0].vimage_url?env.imgBaseUrl + item.positionContentList[0].vimage_url:'';
				uni.setStorageSync('shareImg',simg)
			}
			
		}
		const scont = res.object&&res.object.vshare_title?res.object.vshare_title:'';
		uni.setStorageSync('shareTitles',scont)
		console.log('advList',advList.value)
	}

	const getTotalCouponAmount = async () => {
		try {
			// showLoading()
			let res = await getSpecialFood({ curPage: pageInfoTj.value.curPage, pageSize: pageInfoTj.value.pageSize, shopId: shopStore.curSellerMemberId })   //shopStore.curSellerMemberId  16703
			console.log('特价菜品----------------------------', res)
			if (!res.result) {
				specList.value = []
				return
			}
			// res.object.forEach((item : any) => {
			// 	let match = item.vname.match(/^(\d+g)/);
			// 	item.vname = match ? match[0] : ''; // 更新 vname 为提取的部分
			// })
			specList.value = res.object
		} catch (e) {
			hideLoading();
			mapi.msg('获取数据失败!');
		}
	}
	
	const getMealOrder = async () => {
		try{
			let res = await getMealsOrder();
			if (!res.result) {
				mapi.msg('网络繁忙，请稍后再试!'||res.shortMessage,res.code);
				return
			}
			mealsOrderList.value = res.object||[];
			
		}catch(e){
			console.error(e)
		}
		
	}
	const getAcounts = async () => {
		// smid: '' 
		let res = await getCredAccount({ channelNo: "1114", smid: shopStore.curSellerMemberId })
		if (!res.result) {
			return
		}
		assountMoney.value = res.object.total_money
		discountNums.value = res.object.minDiscount || "8.5"
	}
	const dragTouchend = (params : any) => {
		dragDirect.value = params.direction;
	}
	// 分享好友
	onShareAppMessage(() => {
		return new Promise(async (resolve, reject) => {
			let param = {
				event_id: '19', //事件id  1:会员注册, 2:H5分享， 3:商品价格标签, 4:商品超链接分享, 5:拼团， 6:线下团购,7.总部推广 ,8.VIP专属卡,9.预留1,10.预留2
				source_type: '1', //1首页分享，2商品分享，3名片分享，4商品超链接分享5拼团,6线下团购,7.总部推广 ,8.VIP专属卡,9.预留1,10.预留2
				goods_id: '',
				goods_sku: '',
				activity_id: '',
				sell_member_id: shopStore.curSellerMemberId || '', //门店id
				// buy_member_id: paramData.buy_member_id || '', //用户id
			}
			try {
				let shareId = await takeSaveShare(param)
				if (shareId) {
					const imageUrl = uni.getStorageSync('shareImg')
					const shareTits=uni.getStorageSync('shareTitles')
					let msg = {
						title:shareTits || '好食材 健康外卖',
						content:'好食材 健康外卖',
						path: '/pages/index/home/home?scene=' + shareId,
						imageUrl: imageUrl||'https://cdn-static.yekjx.com/resouces/daiyan/xyyy_share.png',
					}
					resolve(msg)
				} else {
					reject('');
					mapi.msg('分享失败,请稍后重试')
				}
			} catch (e) {
				reject('');
				mapi.msg('分享失败,请稍后重试')
				console.error(e)
				//TODO handle the exception
			}

		});
	});
	// const loadMethod = (obj,s)=>{
	// 	console.log('p1,p2,p3', obj,s);
	// }
	onLoad(async (options) => {
		console.log('options', options);
		isPhonex.value = getSystemPhoneX();
		const deviceInfo = uni.getDeviceInfo()
		const systemSetting = uni.getSystemSetting()
		const windowInfo = uni.getWindowInfo()
		let e={...deviceInfo,...systemSetting,...windowInfo}
		marginTop.value = Number(e.statusBarHeight) + 38
		console.log(' marginTop.value-----------------------------------------------------', marginTop.value)
		// #ifndef MP
		state.statusBar = Number(e.statusBarHeight);
		if (e.platform == 'android') {
			state.customBar = Number(e.statusBarHeight) + 50;
		} else {
			state.customBar = Number(e.statusBarHeight) + 45;
		}
		// #endif
		// #ifdef MP-WEIXIN
		state.statusBar = Number(e.statusBarHeight);
		let custom = wx.getMenuButtonBoundingClientRect();
		state.customBar = custom.bottom + custom.top - Number(e.statusBarHeight);
		// #endif
		// #ifdef MP-ALIPAY
		// state.statusBar = Number(e.statusBarHeight);
		// state.customBar = Number(e.statusBarHeight) + Number(e.titleBarHeight);
		// #endif
		
		// uni.getSystemInfo({
		// 	success: function (e) {
		// 		marginTop.value = Number(e.statusBarHeight) + 38
		// 		console.log(' marginTop.value-----------------------------------------------------', marginTop.value)
		// 		// #ifndef MP
		// 		state.statusBar = Number(e.statusBarHeight);
		// 		if (e.platform == 'android') {
		// 			state.customBar = Number(e.statusBarHeight) + 50;
		// 		} else {
		// 			state.customBar = Number(e.statusBarHeight) + 45;
		// 		}
		// 		// #endif
		// 		// #ifdef MP-WEIXIN
		// 		state.statusBar = Number(e.statusBarHeight);
		// 		let custom = wx.getMenuButtonBoundingClientRect();
		// 		state.customBar = custom.bottom + custom.top - Number(e.statusBarHeight);
		// 		// #endif
		// 		// #ifdef MP-ALIPAY
		// 		state.statusBar = Number(e.statusBarHeight);
		// 		state.customBar = Number(e.statusBarHeight) + Number(e.titleBarHeight);
		// 		// #endif
		// 	}
		// });
		// 分享id解析
		if (options.scene) {
			try {
				
				let shreS= decodeURIComponent(options.scene)
				// shreS.split('=')[1] 
				let sdetail = await getShareDetail({ share_id: options.scene})
				if (sdetail.result && sdetail.object) {
					let nres = JSON.parse(sdetail.object.request_params);
					console.log('getShareDetail', nres);
					let nparam = {
						shareMemberId: '',
						buy_member_id:nres.buy_member_id||'',
						sellMemberId: nres.sell_member_id || '',//暂
						share_id: options.scene || '',
						event_id_1: nres.event_id || ''
					}
					shopStore.setQrShop(nres.sell_member_id || '')
					checkOrg(nparam)
					initShop(loadData, { source: 'init' });
					return
				}
				initShop(loadData, { source: 'init' });
			} catch (e) {
				initShop(loadData, { source: 'init' });
				console.error(e);
			}
			return
		}
		nextTick(() => {
			prcy.value.checkPrivacySetting();
			initShop(loadData, { source: 'init' });
		})
	});
	const loaded = ref(false)
	const curRoute = ref('')
	onShow(() => {
		autoPlay.value = true;
		curRoute.value = getCurRoute();
		loaded.value && initShop(loadData, { source: 'init' });
		// loaded.value && getLikeList('refresh')
		 // getTotalCouponAmount()
		// checkLogin() && getAcounts()
		// getSwipers()
	})
	onHide(()=>{
		autoPlay.value = false;
	})
	const changeList = e => {
		// state[e.name].push(e.value)
	};

	const loadData = (param : any) => {
		// const { data } = await getData();
		console.log('loadData', param);
		showLoading();
		getSwipers();
		getTotalCouponAmount();
		getLikeList(param.source);
		getAcounts();
		checkLogin()&&getMealOrder();
		// getAcounts()

	}
	
	const getLikeList = async (source : any = 'add') => {
		showLoading()
		if (source == 'init') {
			pageInfo.value.curPage = 1
			pageInfo.value.backCupPage = 2
		}
		if (pageInfo.value.curPage > pageInfo.value.backCupPage && source != 'init') {
			console.log("没有更多啦")
			return
		}
		let res = await getGoodsLikeList({ curPage: pageInfo.value.curPage, pageSize: pageInfo.value.pageSize })
		loaded.value = true
		if (!res.result) {
			// if (res.shortMessage == '用户未登录') {
			// 	mnavTo('/pages/login/login')
			// }
			hideLoading()
			return
		}
		pageInfo.value.curPage += 1
		pageInfo.value.backCupPage = res.page.totalPage || 0
		if (source == 'refresh' || source == 'init') {
			// source == 'refresh'&& mapi.msg('刷新成功!');
			waterFulls.value.list = [];
			waterFulls.value.list1 = [];
			waterFulls.value.list2 = [];
		}
		let nres = res.object;
		let iszan = false;
		let iscai = false;
		waterFulls.value.list = nres;
		for (let i in nres) {
			const item = nres[i];
			if (item.likeFlag === '5') {
				iszan = true;
				iscai = false;
			} else if (item.likeFlag === '6') {
				iszan = false;
				iscai = true;
			} else if (item.likeFlag === null) {
				iszan = false;
				iscai = false;
			}
			if (Number(i) % 2 == 0) {
				waterFulls.value.list1.push({
					...nres[i],
					src: nres[i].vmaster_product_image_id,
					iscai: iscai,
					iszan: iszan,
					title: nres[i].content,
					desc: ''
				})
			} else {
				waterFulls.value.list2.push({
					...nres[i],
					src: nres[i].vmaster_product_image_id,
					iscai: iscai,
					iszan: iszan,
					title: nres[i].content,
					desc: ''
				})
			}
		}
		console.log(waterFulls.value, "waterFulls.valuewaterFulls.value")
	}

	const tapzItem = async (item : any, type : string) => {
		let res = await getlikeorStepon({ isLikes: type == 'cai' ? 0 : 1, goodsDiscussId: item.goods_discuss_id })
		if (!res.result) {
			mapi.msg("网络繁忙，请稍后再试!",res.code)
			return
		}

		if (res.object.cussTag == '5') {
			item.iszan = true
			item.iscai = false
			item.nfavourable_nums = res.object.like_num
		} else if (res.object.cussTag == '6') {
			item.iszan = false
			item.iscai = true
			item.nfavourable_nums = res.object.like_num
		} else {
			item.iszan = false
			item.iscai = false
			item.nfavourable_nums = res.object.like_num
		}

		// if (type == 'cai') {
		//     // 切换“踩”状态
		//     if (item.iscai) {
		//         // 已经踩了，取消踩
		//         item.iscai = false;
		//     } else {
		//         // 没有踩，执行踩操作
		//         item.iscai = true;
		//         if (item.iszan) {
		//             // 如果之前点赞了，则取消点赞
		//             item.iszan = false;
		//             item.nfavourable_nums -= 1; // 取消点赞时数字减一
		//         }
		//     }
		// } else {
		//     // 切换“赞”状态
		//     if (item.iszan) {
		//         // 已经赞了，取消赞
		//         item.iszan = false;
		//         item.nfavourable_nums -= 1; // 取消赞时数字减一
		//     } else {
		//         // 没有赞，执行赞操作
		//         item.iszan = true;
		//         item.nfavourable_nums += 1; // 点赞时数字加一
		//     }
		//     // 同时取消“踩”状态
		//     if (item.iscai) {
		//         item.iscai = false; // 如果已经踩了，取消踩
		//     }
		// }

	}
	const changeMenuCach = (type : string, obj : any, url : string) => {
		// ={id:any,source:string,action:string}
		type == 'add' ? uni.setStorageSync('menuact', obj) : uni.removeStorageSync('menuact')
		uni.switchTab({
			url
		})

	}

	//顶部nav跳转
	const tapNavItem = (item : any) => {

		console.log(item)
		const { vaction_type, url } = item;
		
		if (vaction_type === '930') {
		    uni.navigateToMiniProgram({
		        appId: 'wx4a1facb7c2cfbd34',
		        path: url,
		        success(res) {
		            // 打开成功
		        }
		    });
         // mnavTo('/pages/order/setMealCreatOrder/setMealCreatOrder')
		} else if (vaction_type === '931' && url) {
		    if (url.includes('yuding')) {
		        changeMenuCach('add', { id: '1', source: 'home', action: 'yuding' }, url);
		    } else {
		        uni.switchTab({
		            url
		        });
		    }
		} else if (url) {
		    mnavTo(url);
		}
		// if (item.type == '1232') {
		// 	changeMenuCach('add', { id: '1', source: 'home', action: 'yuding' }, item.url)
		// 	return
		// }
		// // if (item.type == '1232') {
		// // 	uni.switchTab({
		// // 	  url:item.url
		// // 	})
		// // 	return
		// // }
		// if (item.type == '1397') {
		// 	uni.navigateToMiniProgram({
		// 		appId: 'wx4a1facb7c2cfbd34',
		// 		path: item.url,
		// 		// extraData: {
		// 		//   'data1': 'test'
		// 		// },
		// 		success(res) {
		// 			// 打开成功
		// 		}
		// 	})
		// 	return
		// }
		// item.url && mnavTo(item.url)
	}
	//底部按钮
	const tapToMenu = (item:any) => {
		// uni.switchTab({url:'/pages/index/menu/menu'})
		mnavTo(`/pages/order/manyMeal/manyMeal?hasRecord=true&fbillId=${item.bill_id}&goodsId=${item.goods_id}&sellerMemberId=${item.sell_member_id}`,true);
	}
	const toTopClick = () => {
		state.isShowToTop = false; // 回到顶部按钮需要先隐藏,再执行回到顶部,避免闪动
		state.scrollTop = 0
		// uni.pageScrollTo({
		// 	scrollTop: 0,
		// 	duration: 300,
		// });
	};
	// const titChange = (e)=>{
	// 	console.log('titChange',e)
	// }
	const boxScroll = (e) => {
		state.scrollTop = e.scrollTop;
	};
	// let emit = defineEmits([
	//   "change"
	// ]);
	// const onChange = type => {
	// 	emit('change', type)
	// };
	// ====>old
	// export default {
	// 	name: 'homeModal1',
	// 	emits: ['change'],
	// 	props: {
	// 		title: {
	// 			type: String,
	// 			default: ''
	// 		}
	// 	},
	// 	methods: {
	// 		onChange(type) {
	// 			this.$emit('change', type)
	// 		}
	// 	}
	// }
</script>

<style lang="scss">
	.imgEmpty {
		// margin-top: 165rpx;
		position: absolute;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
		z-index:2;
		background: #f5f5f5;
		.emtimg {
			animation: skeleanimate 1.2s ease-in-out infinite;
			width: 100%;
			height: 100%;
		}
	}

	@keyframes skeleanimate {

		0%,
		100% {
			opacity: 1;
		}

		50% {
			opacity: 0.8;
		}
	}

	.marLeft12 {
		margin-left: 12rpx;
	}

	.imms {
		width: 100%;
		height: 352rpx;
	}

	.u-image__error {
		top: 10rpx !important;
	}

	.container {
		background: #F8F8F8;
		width: 100vw;
		height: 100vh;
	}

	.padmbot {
		padding-bottom: 200rpx;
	}

	.topSec {
		width: 100vw;
		min-height: 460rpx;
		background: linear-gradient(164deg, #09EC8D -57.6%, #FFF 62.77%);
		box-shadow: 0px -1px 2px 0px rgba(0, 0, 0, 0.06);


	}

	.bg_boxx {
		background: linear-gradient(180deg, #FFF 0%, #F8F8F8 100%);
	}

	.navBox {
		padding-left: 13rpx;

	}

	.navItem {
		width: 145rpx; //142
		min-height: 140rpx;

		// &.lg{
		// 	width: 172rpx;
		// 	min-height: 160rpx;
		// }
		.icoimg {
			width: 120rpx;
			height: 120rpx;
			font-size: 0;
		}

		.nvtext {
			margin-top: -8rpx;
		}
	}

	.nadm_cont {
		@include baseab(232rpx, 232rpx, 3);
		left: 52rpx;
		top: 0;

		// background: #09EC8D;
		.nad_tit {
			// @include centBox(100%,84rpx);
			width: 100%;
			height: 84rpx;
			background: #FF453E;
			border-radius: 20rpx;
			border-radius: 10px;
			box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.30) inset;
		}

	}

	.nadtext {
		margin-top: 3rpx;
	}

	.nad_line {
		height: 4rpx;
		width: 1px;

		&:before {
			content: '';
			position: absolute;
			left: 0;
			top: 0;
			@include baseab(46rpx, 4rpx);
			background: linear-gradient(90deg, #FF9B94 0%, rgba(255, 255, 255, 0.00) 100%);
		}

		&.lef {
			&:before {
				left: auto;
				right: 0;
				background: linear-gradient(90deg, rgba(255, 255, 255, 0.00) 0%, #FF9B94 100%);
			}
		}
	}

	.specSec {
		width: calc(100vw - 60rpx);
		border-radius: 20rpx;
		border: 1px solid #FFF;
		background: linear-gradient(149deg, #FAF6F1 2.56%, #DCF6E6 94.25%);
		padding: 10rpx 14rpx 25rpx;

		.mspbtn {
			color: rgba(91, 175, 134, 0.6);
		}

		.spe_box {
			display: flex;
			justify-content: flex-start;
			align-items: center;
		}

		.spe_cel {
			width: 153rpx;
			margin: 8rpx 18rpx 0 0;
			border-radius: 16rpx;
			border: 1rpx solid #FFF;
			background: #FFF;
			padding: 15rpx 2rpx 12rpx 4rpx;
			&:nth-last-child(1){
				margin: 8rpx 0 0 0;
			}
		}

		.padtmd {
			// padding-top: 16rpx;
			text-align: center;
		}
	}

	.minh38 {
		min-height: 38rpx;
		padding-top: 8rpx;
	}

	.text48 {
		font-size: 48rpx;
	}

	.lsItem {
		width: calc(((100vw - 90rpx)/2)); //320
		min-height: 492rpx;
		border-radius: 20rpx;
		margin-top: 20rpx;

		// margin: 20rpx 0 0 30rpx;
		.itm_cont {
			min-height: calc(492rpx - 352rpx);
			border-radius: 0 0 20rpx 20rpx;
		}

	}

	.fcon-yizan1 {
		color: #EF0606;
	}

	.fcon-yicai1 {
		color: #BDBDBD;
	}

	.lefsld {
		&:before {
			content: '';
			@include baseab(2rpx, 36rpx);
			left: -10rpx;
			top: 12rpx;
			background: rgba(153, 153, 153, 0.2);
		}

	}

	.itm_txt {
		padding: 20rpx 16rpx 0 16rpx;
		min-height: 56rpx;
	}
	.swboxdt{
		
		height: 130rpx;
	}
	.botSec {
		position: fixed;
		left: 30rpx;
		bottom: 10rpx;
		z-index: 3;
		width: calc(100vw - 60rpx);
		height: 130rpx;
		border-radius: 60rpx;
		border: 1px solid #9F9664;
		background: #343333;

		.texta7 {
			color: #A7A8B7;
		}

		.bs_btn {
			@include centBox(196rpx, 60rpx);
			border-radius: 60rpx;
			background: #F7D06E;

		}

		.mrtwf {
			padding-right: 24rpx;
		}
	}

	.top_box {
		position: fixed;
		right: 30rpx;
		bottom: 180rpx;
		font-size: 64rpx;
		z-index: 2;
		color: #DFDFDF;

		.tpico {
			width: 64rpx;
			height: 64rpx;
			background: rgba(255, 255, 255, 0.5);
			border-radius: 50%;
		}
	}

	.nullVip_t {
		color: #333;
		text-align: center;
		font-size: 20rpx;
		font-weight: 700;
		margin-top: 20rpx;
	}

	.nullVip_t_sub {
		color: #999;
		font-family: "Microsoft YaHei UI";
		font-size: 20rpx;
		font-weight: 400;
		margin-top: 10rpx;
	}

	.nullVip_t_sub_d {
		color: #333;
		font-family: "Microsoft YaHei UI";
		font-size: 19rpx;
		font-weight: 400;
		margin-top: 10rpx;
		letter-spacing: -0.1rpx;
	}

	.nullVip_toView {
		width: 152rpx;
		height: 46rpx;
		border-radius: 100rpx;
		background: #FF453E;
		margin: 20rpx auto;
		line-height: 46rpx;
		color: #FFF;
		text-align: center;
		font-size: 24rpx;
		font-weight: 400;
		letter-spacing: 0.6rpx;
	}

	.Vipcoupon-con {
		// position: relative;
		bottom: 184rpx;
		right: 26rpx;
		background: url('https://cdn-static.yekjx.com/shop/images/home_coup01.png');
		background-size: 220rpx 290rpx;
		width: 220rpx;
		height: 290rpx;
		// z-index: 12;

		.text-con {
			color: #333;
			font-size: 24rpx;
			font-weight: 400;
			margin-top: 25rpx;
		}

		.text-con1 {
			color: #333;
			font-size: 28rpx;
			font-weight: 700;
			margin-top: 15rpx;
		}

		.ipcoupon-fwxm {
			color: #FFF;
			font-size: 20rpx;
			font-weight: 400;
			text-align: center;
			height: 45rpx;
			line-height: 54rpx;
		}

		.ipcoupon-zigh1 {
			color: #999;
			text-align: center;
			font-size: 20rpx;
			font-weight: 400;
		}

		.ipcoupon-zigh {
			color: #333;
			text-align: center;
			font-size: 20rpx;
			font-weight: 400;
			line-height: 15rpx;
		}

		.ipcoupon-dazhe {
			color: rgba(255, 255, 255, 0.70);
			font-size: 28rpx;
			font-weight: 400;

			.txtt {
				color: #FFF;
				font-size: 28rpx;
				font-weight: 700;
				margin-left: 6rpx;
			}
		}

		.vipcoupon-btn1 {
			width: 145.024rpx;
			height: 49.878rpx;
			border-radius: 30px;
			background: #FFEBC6;
			color: #000;
			font-size: 28rpx;
			font-weight: 400;
			margin: 15rpx auto;
		}

		.vipcoupon-btn {
			width: 145.024rpx;
			height: 49.878rpx;
			flex-shrink: 0;
			border-radius: 30px;
			background: #FFEBC6;
			color: #000;
			font-size: 28rpx;
			font-weight: 400;
			margin: 5rpx auto;
		}

		.text-pic {
			color: #FF0E0E;
			font-size: 24rpx;
			font-weight: 400;
			align-items: flex-start;
			margin-top: 5rpx;
			margin-bottom: 5rpx;

			.txtv {
				&:first-child {
					margin-top: 10rpx;
					margin-right: 8rpx;
				}

				&:last-child {
					font-size: 48rpx;
					font-weight: 700;
				}

				.pic_subtext {
					color: #333;
					font-family: "Microsoft YaHei UI";
					font-size: 24rpx;
					font-weight: 400;
				}

				.pic_ss {
					color: #333;
					font-family: "Microsoft YaHei UI";
					font-size: 20rpx;
					font-weight: 400;
				}
			}
		}
	}

	.coup_bottom_style {
		width: 100%;
		height: 148rpx;
		// background-color: blanchedalmond;
		position: absolute;
		bottom: 0;
		left: 0;
		text-align: center;
	}
</style>